﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace GSAClient
{
    class Product
    {
        private Dictionary<String, List<String>> attributes;
        private String id, title, link, image_link, description;
        private decimal price;

        public Product()
        {
            attributes = new Dictionary<String, List<string>>();
        }

        public String getID()
        {
            return this.id;
        }

        public String getTitle()
        {
            return this.title;
        }

        public String getLink()
        {
            return this.link;
        }

        public void setLink(String link)
        {
            this.link = link;
        }

        public List<String> getAttribute(String name)
        {
            return this.attributes[name];
        }

        public void addAttribute(String name, String value)
        {
            switch (name)
            {
                case "id":
                    this.id = value;
                    break;
                case "title":
                    this.title = value;
                    break;
                case "image_link":
                    this.image_link = value;
                    break;
                case "price":
                    this.price = Convert.ToDecimal(value);
                    break;
                case "description":
                    this.description = value;
                    break;
            }
            List<String> curr;
            if (attributes.ContainsKey(name))
                curr = attributes[name];
            else
                curr = new List<String>();

            curr.Add(value);
            this.attributes.Remove(name);
            this.attributes.Add(name,curr);           
        }       
    }
}
